package com.example.mall.service.impl;

import com.example.mall.mbg.mapper.WeightMapper;
import com.example.mall.mbg.model.Weight;
import com.example.mall.mbg.model.WeightExample;
import com.example.mall.service.WeightService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * WeightServiceImpl
 * Created by on 2023/12/27.
 */
@Service
public class WeightServiceImpl implements WeightService {
    @Autowired
    private WeightMapper weightMapper;

    @Override
    public List<Weight> listAll() {
        return weightMapper.selectByExample(new WeightExample());
    }

    @Override
    public int create(Weight weight) {
        return weightMapper.insertSelective(weight);
    }

    @Override
    public int update(Integer weightid, Weight weight) {
        weight.setWeightid(weightid);
        return weightMapper.updateByPrimaryKeySelective(weight);
    }

    @Override
    public int delete(Integer weightid) {
        return weightMapper.deleteByPrimaryKey(weightid);
    }

    @Override
    public List<Weight> list(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return weightMapper.selectByExample(new WeightExample());
    }

    @Override
    public Weight get(Integer weightid) {
        return weightMapper.selectByPrimaryKey(weightid);
    }
}
